<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        //要求：
        //编写一个函数calculateAverage，接受一个数字数组作为参数，并返回数组的平均值。
    function calculateAverage(numbers) {
        if (numbers.length === 0) {
            return 0;
        }
        let sum = 0;
        for (let i = 0; i < numbers.length; i++) {
            sum += numbers[i];
        }
        return sum / numbers.length; 
    }
    
    console.log(calculateAverage([1, 2, 3])); 
    
    </script>
</body>
</html>